
#import "RIBSides.h"

@implementation RIBSides


+ initialize { return [RIBSides setVersion:1], self; }

- init
{
  [super init];

  sides = 2;
  
  return self;
}

- setSides:(RtInt)newSides
{
  if ((newSides < 1) || (newSides > 2))
  {  NXLogError("warning: a RIBSides object can only have a value of 1 or 2 sides: %d isn't valid\n", 
		newSides);
     return self;
  }
  sides = newSides;
  return self;
}

- (RtInt)sides { return sides; }

- renderSelf:(WW3DCamera *)camera startingAt:(RtFloat)shutterOpenTime endingAt:(RtFloat)shutterCloseTime
{
  RiSides(sides);

  return self;
}

- writeEve:(NXStream *)stream atTabLevel:(int)tab
{
   int  i;


   for (i = 0; i < tab; i++)
   {  NXPrintf(stream, "\t");
   }
   NXPrintf(stream, "Sides %d;", sides); 
   return self;
}

#define typeVector "d"
#define typeValues &sides

- read:(NXTypedStream*)stream 
{
    int version;
    [super read:stream];

    version = NXTypedStreamClassVersion(stream,"RIBSides");
    if (version == 0) NXReadTypes(stream, "i", &version), version=1;
    if (version == 1)
    {  NXReadTypes(stream, typeVector, typeValues);
    } 
    else 
    {
    }
    return self;
}

- write:(NXTypedStream*)stream 
{
    [super write:stream];

    NXWriteTypes(stream, typeVector, typeValues);

    return self;
}


@end
